package com.lngsyz.ywtb.biz.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lngsyz.ywtb.entity.source1.GsYwtbSeal;
import com.lngsyz.ywtb.entity.source1.YwtbCityOrderSeal;
import com.lngsyz.ywtb.mapper.source1.GsYwtbSealMapper;

import net.logstash.logback.encoder.org.apache.commons.lang.StringUtils;

@Service
public class GsYwtbSealService {
    
	@Autowired
	GsYwtbSealMapper gsYwtbSealMapper;
	
    public List<GsYwtbSeal> findByMainId(String mainId){
    	Map<String, Object> param = new HashMap<String, Object>();
    	if(StringUtils.isNotBlank(mainId)) {
    		param.put("mainId", mainId);
    		List<GsYwtbSeal> lists = gsYwtbSealMapper.findByCondition(param);
    		return lists;
    	} else {
    		return new ArrayList<GsYwtbSeal>(); 
    	}
    }
    
    public List<GsYwtbSeal> packageYwtbSeals(List<YwtbCityOrderSeal> ywtbCityOrderSeals){
    	List<GsYwtbSeal> seals = new ArrayList<GsYwtbSeal>();
    	for(YwtbCityOrderSeal ywtbCityOrderSeal : ywtbCityOrderSeals) {
    		GsYwtbSeal seal = new GsYwtbSeal();
			seal.setSealId(ywtbCityOrderSeal.getSealId());
			seal.setPripid(ywtbCityOrderSeal.getPripid());
			seal.setSealType(ywtbCityOrderSeal.getSealType());
			seal.setSealMedia(ywtbCityOrderSeal.getSealMedia());
			seal.setSealMaterial(ywtbCityOrderSeal.getSealMaterial());
			seal.setPrice(ywtbCityOrderSeal.getPrice().toString());
			seal.setMainId(ywtbCityOrderSeal.getId());
			seal.setReferSealId(ywtbCityOrderSeal.getReferSealId());
			seals.add(seal);
    	}
    	return seals;
    }
}
